<?php
/**
 * Created by PhpStorm.
 * User: tronke
 * Date: 2017/5/25
 * Time: 14:16
 */

header("Access-Control-Allow-Origin:*");
// 一、判断有没有传递至过来

if(!empty($_POST)&&$_POST["loginemain"]&&$_POST["loginpwd"])


// 1.建立连接
// 1.1  服务的地址
    $dbServer = "127.0.0.1";
    $dbUser = "root";
    $dbPwd = "";
    $database = "hy";
// C == Class
    $connection = new mysqli($dbServer, $dbUser, $dbPwd, $database);
//1.2  配置一个连接的字符集
    mysqli_query($connection, "set names utf8");//给的$connection的字符串设置字符集
//2.准备sql语句
    $sql = "SELECT*FROM userinfo WHERE uEmail='" . $_POST["loginemain"] . "' AND uPwd='" . $_POST["loginpwd"] . "'";
//3 执行sql，返回结果
    $result = $connection->query($sql);

    if ($result->num_rows == 1) {
        $arr = array("status" => 1, "msg" => "登录成功"); //关联数组
        print_r(json_encode($arr));

    } else {
        $arr = array("status" => 0, "msg" => "登录失败,用户名或密码错误！");
        print_r(json_encode($arr));
    }


//4.关闭连接
    $connection->close();
